<?php
class CardsModel extends Model{
	//自动验证
	protected $_validate = array(
		array('card_id','require','缺少卡号！'),
		array('card_id','require','缺少密码！'),
		array('card_amount','require','缺少额度！'),
	);
	
	//自动填充
	protected $_auto = array(
		array('card_static','0'),
		array('card_userid','0'),
		array('card_paiddate','setTime',self::MODEL_BOTH,'callback'),
		array('card_generatedate','setTime',self::MODEL_BOTH,'callback')
	);
	
	//取得当前时间
	protected function setTime()
	{
		return date("Y-m-d H:i:s");
	}
	
	//数据表字段
	protected $fields = array(
		'card_id',
		'card_password',
		'card_amount',
		'card_static',
		'card_userid',
		'card_paiddate',
		'card_generatedate',
		'_pk'=>'card_id', //主键
		'_autoInc'=>true //是否自增
		);
}
?>